﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;

namespace Kokomo
{
	public static class DependencyObjectExtensions
	{
		public static TAncestor FindAncestor<TAncestor>(this DependencyObject obj)
			where TAncestor : DependencyObject
		{
			while (obj != null)
			{
				obj = VisualTreeHelper.GetParent(obj);
				if (obj is TAncestor) return (TAncestor)obj;
			}

			return null;
		}
	}
}
